#!/bin/sh
#welcome

export TEXTDOMAIN=welcome1stboot
export OUTPUT_CHARSET=UTF-8

read -r ISSUE ETC < /etc/issue
W_MSG="$(gettext "Welcome,
This is the first time you are running ${ISSUE}!...")"

CONNECTED=$(LANG=C [ "$(route -n | awk 'FNR == 3 {print $2}')" != "0.0.0.0" ] && \
	grep -wq nameserver /etc/resolv.conf && \
	echo -n yes || echo -n no
)

if [ "$CONNECTED" = "yes" ] ; then
	LABEL_INTERNET="$(gettext "Congratulations, you seem to be connected to the Internet. Experiment with mouse-over, left-click and right-click on the 'network' icon in the tray. Click on the icon on the right (or on the desktop) if you need to reconfigure the Internet connection")"
elif [ "$(ifconfig -a | cut -f 1 -d " " | sed -e "/^$/d" -e '/^lo$/d')" != "" ] ; then
	LABEL_INTERNET="$(gettext "There is a working network interface, but you are not connected to the Internet. Click on the 'connect' icon on the right, or on left-side of the desktop (do NOT double-click), to setup the Internet connection. Note the network status icon in the tray.")"
else
	LABEL_INTERNET="$(gettext "Click on the button on the right, or icon at left of the screen (one click only!). You will then see some buttons for choosing how you wish to connect to the Internet. It is easy...")"
fi

LABEL_INTERNET="$(gettext "<b>Internet connection</b>
${LABEL_INTERNET}")"
LABEL_NEEDHELP="$(gettext "<b>I need help!</b>
Explore the Menu -- see bottom-left of screen. Lots of local help is available -- select Help in the menu. The local Help page also has the Release Notes for this version of ${ISSUE}-- well worth checking out! When you get online, the web browser home page has many more links.")"
LABEL_SETUP="$(gettext '<b>Setup</b>
Want to install an upgraded video driver? Country localization? Printing? Sound? Mouse? Keyboard? Click here (or 'setup' icon at top of screen).')"

export WELCOME_DIALOG='
<window title="'$(gettext 'Welcome')'" icon-name="gtk-info" resizable="false">
<vbox>
	<hbox border-width="7" space-expand="true" space-fill="true">
      <pixmap icon_size="4"><input file>/usr/share/doc/puppylogo96.png</input></pixmap>
      <text use-markup="true"><label>"<big>'"${W_MSG}"'</big>"</label></text>
    </hbox>
    <hbox border-width="7" space-expand="true" space-fill="true">
      <text space-expand="false" space-fill="false"><label>""</label></text>
      <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'"${LABEL_INTERNET}"'"</label></text>
      <vbox space-expand="false" space-fill="false">
        <button>
          '$(/usr/lib/gtkdialog/xml_button-icon /usr/local/lib/X11/pixmaps/connect48.png huge)'
          <action>/usr/sbin/connectwizard & </action>
        </button>
      </vbox>
    </hbox>
    <hseparator></hseparator>
    <hbox border-width="7" space-expand="true" space-fill="true">
      <text space-expand="false" space-fill="false"><label>""</label></text>
      <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'"${LABEL_SETUP}"'"</label></text>
      <vbox space-expand="false" space-fill="false">
        <button>
         '$(/usr/lib/gtkdialog/xml_button-icon /usr/local/lib/X11/pixmaps/configuration48.png huge)'
         <action>/usr/sbin/wizardwizard & </action>
        </button>
      </vbox>
    </hbox>
    <hseparator></hseparator>

    <hbox border-width="7" space-expand="true" space-fill="true">
      <text space-expand="false" space-fill="false"><label>""</label></text>
      <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'"${LABEL_NEEDHELP}"'"</label></text>
      <vbox space-expand="false" space-fill="false">
        <text space-expand="false" space-fill="false"><label>""</label></text>
        <button>
         '$(/usr/lib/gtkdialog/xml_button-icon help.svg huge)'
         <action>basichtmlviewer file:///usr/share/doc/index.html & </action>
        </button>
      </vbox>
    </hbox>
    <hbox border-width="7" space-expand="true" space-fill="true">
      <pixmap><input file>/usr/share/doc/tray.png</input></pixmap>
      <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'$(gettext "...mouse-over and click the tray applets!")'"</label></text>
    </hbox>
  </vbox>
</window>'

gtkdialog --center -p WELCOME_DIALOG 2>/dev/null

### END ###
